package kr.hkit.bsnsalemgn;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import kr.hkit.bsnsalemgn.inputUI.AbsInputBaseUI;

public class BusinessSaleMgn extends JFrame implements ActionListener {

	private JPanel contentPane;
	private JMenu baseMenu;
	private JMenuItem empMenuItem;
	private JMenuItem pdtMenuItem;
	private JMenuItem bsnMenuItem;
	private JMenu saleMgnMenu;
	private JMenuItem saleMenuItem;
	private JMenu queryMenu;
	private JMenuItem empMgnMenuItem;
	private JMenuItem pdtMgnMenuItem;
	private JMenuItem pdthistoryMenuItem;
	private JMenuItem bsnhistoryMenuItem;
	private JMenuItem bsnMgnMenuItem;
	private JMenuItem emphistoryMenuItem;
	private JPanel panel;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BusinessSaleMgn frame = new BusinessSaleMgn();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BusinessSaleMgn() {
		setTitle("거래처 영업 관리 프로그램");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		baseMenu = new JMenu("기초자료관리");
		menuBar.add(baseMenu);
		
		empMenuItem = new JMenuItem("영업사원관리");
		empMenuItem.addActionListener(this);
		baseMenu.add(empMenuItem);
		
		pdtMenuItem = new JMenuItem("제품관리");
		pdtMenuItem.addActionListener(this);
		baseMenu.add(pdtMenuItem);
		
		bsnMenuItem = new JMenuItem("거래처관리");
		bsnMenuItem.addActionListener(this);
		baseMenu.add(bsnMenuItem);
		
		saleMgnMenu = new JMenu("판매관리");
		menuBar.add(saleMgnMenu);
		
		saleMenuItem = new JMenuItem("판매관리");
		saleMenuItem.addActionListener(this);
		saleMgnMenu.add(saleMenuItem);
		
		queryMenu = new JMenu("조회관리");
		menuBar.add(queryMenu);
		
		empMgnMenuItem = new JMenuItem("영업사원현황");
		empMgnMenuItem.addActionListener(this);
		queryMenu.add(empMgnMenuItem);
		
		pdtMgnMenuItem = new JMenuItem("제품현황");
		pdtMgnMenuItem.addActionListener(this);
		queryMenu.add(pdtMgnMenuItem);
		
		bsnMgnMenuItem = new JMenuItem("거래처현황");
		bsnMgnMenuItem.addActionListener(this);
		queryMenu.add(bsnMgnMenuItem);
		
		bsnhistoryMenuItem = new JMenuItem("거래처별 거래현황");
		bsnhistoryMenuItem.addActionListener(this);
		queryMenu.add(bsnhistoryMenuItem);
		
		pdthistoryMenuItem = new JMenuItem("제품별 거래 현황");
		pdthistoryMenuItem.addActionListener(this);
		queryMenu.add(pdthistoryMenuItem);
		
		emphistoryMenuItem = new JMenuItem("영업사원별 거래 현황");
		emphistoryMenuItem.addActionListener(this);
		queryMenu.add(emphistoryMenuItem);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == saleMenuItem) {
			actionPerformedSaleMenuItem(e);
		}
		if (e.getSource() == bsnMenuItem) {
			actionPerformedBsnMenuItem(e);
		}
		if (e.getSource() == pdtMenuItem) {
			actionPerformedPdtMenuItem(e);
		}
		if (e.getSource() == empMenuItem) {
			actionPerformedEmpMenuItem(e);
		}
		if (e.getSource() == pdtMgnMenuItem) {
			actionPerformedPdtMgnMenuItem(e);
		}
		if (e.getSource() == bsnhistoryMenuItem) {
			actionPerformedBsnhistoryMenuItem(e);
		}
		if (e.getSource() == empMgnMenuItem) {
			actionPerformedEmpMgnMenuItem(e);
		}
		if (e.getSource() == bsnMgnMenuItem) {
			actionPerformedBsnMgnMenuItem(e);
		}
		if (e.getSource() == pdthistoryMenuItem) {
			actionPerformedPdthistoryMenuItem(e);
		}
		if (e.getSource() == emphistoryMenuItem) {
			actionPerformedEmphistoryMenuItem(e);
		}
	}
	protected void actionPerformedEmphistoryMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "영업사원별 거래현황");
	}
	protected void actionPerformedPdthistoryMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "제품별거래현황");
	}
	protected void actionPerformedBsnMgnMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "거래처현황");
	}
	protected void actionPerformedEmpMgnMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "영업사원현황");
	}
	protected void actionPerformedBsnhistoryMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "거래처별 거래 현황");
	}
	protected void actionPerformedPdtMgnMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "제품현황");
	}
	protected void actionPerformedEmpMenuItem(ActionEvent e) {
		AbsInputBaseUI test = new AbsInputBaseUI(0,0) {
			
			@Override
			protected void btnSearchActionPerformed(ActionEvent e) {}
			
			@Override
			protected void btnSaveActionPerformed(ActionEvent e) {}
			
			@Override
			protected void btnDelActionPerformed(ActionEvent e) {}
		};
		contentPane.removeAll();
		contentPane.add(test);
		contentPane.revalidate();
		//test.setVisible(true);
		JOptionPane.showMessageDialog(null, "영업사원관리");
	}
	protected void actionPerformedPdtMenuItem(ActionEvent e) {
		AbsInputBaseUI test = new AbsInputBaseUI(1,-1) {
			
			@Override
			protected void btnSearchActionPerformed(ActionEvent e) {}
			
			@Override
			protected void btnSaveActionPerformed(ActionEvent e) {}
			
			@Override
			protected void btnDelActionPerformed(ActionEvent e) {}
		};
		contentPane.removeAll();
		contentPane.add(test);
		contentPane.revalidate();
		JOptionPane.showMessageDialog(null, "제품관리");
	}
	protected void actionPerformedBsnMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "거래처관리");
	}
	protected void actionPerformedSaleMenuItem(ActionEvent e) {
		JOptionPane.showMessageDialog(null, "판매관리");
	}
}
